package cn.kimming.wms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.kimming.wms.dao.IProductDAO;
import cn.kimming.wms.domain.Product;
import cn.kimming.wms.query.QueryObject;
import cn.kimming.wms.service.IProductService;
import cn.kimming.wms.util.OrderCodeFactory;
import cn.kimming.wms.util.UserContext;

@Service("productService")
public class ProductServiceImpl implements IProductService {

	@Autowired
	private IProductDAO productDAO;
	
	@Override
	public void save(Product obj) {
		obj.setSn(String.valueOf(OrderCodeFactory.getRandom(8)));
		productDAO.save(obj);
	}

	@Override
	public void update(Product obj) {
		productDAO.update(obj);
	}

	@Override
	public void delete(Long id) {
		productDAO.delete(productDAO.get(id));
		
	}

	@Override
	public Product get(Long id) {
		return productDAO.get(id);
	}

	@Override
	public List<Product> list() {
		return productDAO.list();
	}

	@Override
	public List<Product> query(QueryObject qo) {
		return productDAO.query(qo);
	}

	@Override
	public List<Product> listByBrandId(Long id) {
		return productDAO.listByBrandId(id);
	}
}
